/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.his.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.base.BaseEntity;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author his
* @date 2022-11-10
**/
@Entity
@Data
@Table(name="his_report")
public class Report extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`report_id`")
    @ApiModelProperty(value = "序号")
    private Integer reportId;

    @Column(name = "`report_name`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "姓名")
    private String reportName;

    @Column(name = "`sex`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "性别")
    private String sex;

    @Column(name = "`age`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "年龄")
    private Integer age;

    @JoinColumn(name = "`department`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "科室")
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
    private Departments department;

    @JoinColumn(name = "`doctor`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "医生")
    //一个医生------->多个挂号表
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
    private Doctor doctor;

    @JoinColumn(name = "`report_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "挂号类别")
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH})
    private RegisteredType reportType;

    @Column(name = "`price`")
    @ApiModelProperty(value = "挂号费")
    private Double price;

    @Column(name = "`time`")
    @ApiModelProperty(value = "时间")
    private Timestamp time;

    @Column(name = "`users`")
    @ApiModelProperty(value = "操作员")
    private String users;

    @Column(name = "`state`")
    @ApiModelProperty(value = "状态")
    private Integer state;

    @Column(name = "`phone`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "手机号")
    private String phone;

    @Column(name = "`car_id`")
    @ApiModelProperty(value = "carId")
    private String carId;

    @Column(name = "`pathogeny`")
    @ApiModelProperty(value = "病因")
    private String pathogeny;


    public void copy(Report source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
